<?php

class test_tax extends Toast {

    private $tax_sevice;
    private $product;

    public function  _pre() {
        $this->tax_sevice = new service_l_tax();
        $this->product = new product_m_product();
        $this->product->get_by_id(1);//product 1 should have GST and PST
    }

    public function   _post() {
        unset ($this->tax_sevice);
    }

    public function __construct() {
        parent::__construct(__FILE__,"tax");
        $order_tax = new order_tax_m_tax();        
    }

    public function test_product_has_tax_exemtion(){
        $e = $this->tax_sevice->get_exemption(1);
        $this->_assert_not_empty($e);
        $this->_assert_equals(2, $e->result_count());
        $this->user_msg = "Product with id 1 has two tax exemtions";
    }

    public function test_order_tax_calculation(){
        $amount = $this->tax_sevice->calculate_order_items_tax(1);
        foreach ($amount as $a){
            $this->_assert_not_equals(0.00, $a);
        }
        $this->user_msg = "order with id 1 has all kind of taxes GST PST HST";
    }

    public function test_product_tax_calculation(){
        $taxes = $this->tax_sevice->calculate_product_tax(4);
        $this->_assert_equals(0.00, $taxes[1]);
        $this->user_msg = "Product with id#4 do not have GST..only PST and HST";
    }

    public function test_tax_classes(){
        $classes = $this->tax_sevice->get_tax_classes();        
        $this->_assert_equals(3, count($classes));
        $this->user_msg = "System has three TAX classes ";
    }

     public function test_tax_classes_indexed_by_tax_id(){
        $classes = $this->tax_sevice->get_tax_classes();
        $first = array_keys($classes);
        $this->_assert_equals(1, $first[0]);
        $this->user_msg = "Result array is indexed by tax id which starts with 1 ";
    }

}

?>